from tools.utils import do_rest
from api.base.sys.user.queryInfoPage import QueryInfoPage
from tools.base_64 import encrypt_str

que = QueryInfoPage()


class ResetUserPasswdByAdmin():
    """修改用户的密码"""

    def __init__(self):
        self.url = 'https://xxxxxx/xx'

    def change_user_pwd(self, opName, new_pwd):
        """输入用户账号和新密码来修改密码"""
        user_id = que.query_user(opName)['data']['data'][0]['op']['id']
        # print(user_id)
        new_pwd = encrypt_str(new_pwd)
        new_pwd = str(new_pwd, 'utf-8')
        data = {"userId": user_id, "newPasswd": new_pwd}
        re = do_rest(self.url, data, 'post')
        return re.json()

#
# a = ResetUserPasswdByAdmin()
# a.change_user_pwd('zhuqiqi', 'Lian5169*')
